/*
 	
 * */

	//创建div酒席
function Adddata(xishu){
	var div = document.createElement("div");	
	var str = 
	'<div class="bigtable">第'+xishu+'席</div>'+
	'<div class="zhuowei a1"><i class="iconfont icon-lianxiren"></i></div>'+
	'<div class="zhuowei a2"><i class="iconfont icon-lianxiren"></i></div>'+
	'<div class="zhuowei a3"><i class="iconfont icon-lianxiren"></i></div>'+
	'<div class="zhuowei a4"><i class="iconfont icon-lianxiren"></i></div>'+
	'<div class="zhuowei a5"><i class="iconfont icon-lianxiren"></i></div>'+
	'<div class="zhuowei a6"><i class="iconfont icon-lianxiren"></i></div>';	
	div.innerHTML = str;
	div.setAttribute('class','jiuxishu');
	return div;
}

	var storage = window.localStorage;
	var contentmsg = document.getElementById('content');
	var index = localStorage.getItem("index");
	
	for(var i=0;i<index;i++){
		var div = Adddata(i+1);
		contentmsg.appendChild(div);	
	}
	var section = document.getElementsByTagName('section')[0];
	var bigtable = section.querySelector('.bigtable');
	var table_tc = document.querySelector('.table-tc');
	var tc_tablemsg = table_tc.getElementsByClassName('bigtable')[0];
	var jiuxishu = contentmsg.getElementsByClassName('jiuxishu');
	var zhubing = document.querySelector('.zhubing');
	var  jiuxishu_tc = table_tc.querySelector('.jiuxishu');
	var spanmsg = document.getElementsByTagName('span')[0];
	var index_i=0;
	var zhuozihao = document.getElementById('zhuozihao');
	var zuoweihao = document.getElementById('zuoweihao');
	var zhufutc = document.querySelector('.pop-up-windows');
	var closeBtn1 = document.querySelector('.closeBtn1');
	var closeBtn2 = document.querySelector('.closeBtn2');
	var entertc = document.querySelector('.pop-up-windows1');
	var rankingtc = document.querySelector('.pop-up-windows2');
	var ruxiBtn = document.getElementById('ruxiBtn');
	function table(){
		
		closeBtn1.addEventListener('click',function(){	
			zhufutc.style.display = "none";
			rankingtc.style.display= "block";
		});
		closeBtn2.addEventListener('click',function(){//祝福弹窗		
			entertc.style.display = "none";
		});
		ruxiBtn.addEventListener('click',function(){//我要入席弹窗
			entertc.style.display = "none";
		});
		zhubing.addEventListener('click',function(){
			if(bigtable.innerText == "主宾桌"){
				
				table_tc.classList.add("active");
				tc_tablemsg.textContent = "主宾桌";
				zhuozihao.innerText = "主宾";
				table_tc.style.display = "block";
			}
		});

		
		for(let i=0;i<jiuxishu.length;i++){
			jiuxishu[i].addEventListener('click',function(){
				table_tc.classList.add("active");
				table_tc.style.display = "block";
				tc_tablemsg.textContent = "第"+(i+1)+"桌";
				index_i=i+1;
				console.log(index_i);
				zhuozihao.innerText = i+1;
			});
		}	
		tableimg();	
		
	}
	table();
	
	function tableimg(){
		var zuowei = jiuxishu_tc.getElementsByClassName('zhuowei');
		
	$(table_tc).on("click",function(){//推出选座位
			table_tc.style.display = "none";
			
		})
 
		$(jiuxishu_tc).on("click","div.zhuowei",function(e){//点击选座位
			e.stopPropagation();
			var target = this;
			console.log(target)
				for(let k=0;k<zuowei.length;k++){
					zuowei[k].innerHTML = "<i class='iconfont icon-lianxiren'></i>";
				}
				target.innerHTML = "头像";
				zhufutc.style.display = "block";
		});
		
		for(let l=0;l<zuowei.length;l++){
			zuowei[l].addEventListener('click',function(){	
				zuoweihao.innerText = l+1;	
				
			});
		}

	}

	

